package com.wfms.controller;

import com.wfms.bean.User;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

/**
 * Created by chenlei on 2017/9/25.
 */

@RestController
@RequestMapping("/eureka")
public class TestEurekaClient {

    List<User>  users=new ArrayList<>();
    {
        User use1=new User("guoyan",22);
        User user2=new User("zhangsan",11);
        users.add(use1);users.add(user2);
    }


    @GetMapping("hello")
    String hello(){
        System.out.println("receive request....");
        return "hello";
    }

    @GetMapping("user/{id}")
    User getById(@PathVariable("id") int id){
       return  users.stream().findAny().get();
    }

    @PostMapping("user")
    User addUser(@RequestBody User user){
        users.add(user);
        return user;
    }


}
